package com.yesun.dcm.commons.compiler.support;

import com.yesun.dcm.commons.extension.Adaptive;
import com.yesun.dcm.commons.compiler.Compiler;
import com.yesun.dcm.commons.extension.ExtensionLoader;

/**
 * 这个类没看懂，为什么不直接用JavassistCompiler编译呢？是为了扩展吧
 */
@Adaptive
public class AdaptiveCompiler implements Compiler {
    
    @Override
    public Class<?> compile(String code) {
        ExtensionLoader<Compiler> loader = ExtensionLoader.getExtensionLoader(Compiler.class);
        Compiler compiler = loader.getDefaultExtension();
        return compiler.compile(code);
    }
}
